//
//  PersonalCenterHeaderView.m
//  QingBrushTopic
//
//  Created by Zheng on 2017/10/12.
//  Copyright © 2017年 Zheng. All rights reserved.
//

#import "PersonalCenterHeaderView.h"

@implementation PersonalCenterHeaderView

- (instancetype)init {
    self = [super init];
    if (self) {
        
        [self addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
        
        [self addSubview:self.userIconImgv];
        [self addSubview:self.nicknameLbl];
        [self addSubview:self.userIdLbl];
        
        [_userIconImgv mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.mas_equalTo(kCX_Scale(70));
            make.centerY.equalTo(self);
            make.left.mas_equalTo(20);
        }];
        
        [_nicknameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_userIconImgv.mas_right).offset(15);
            make.top.equalTo(_userIconImgv).offset(8);
        }];
        
        [_userIdLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_nicknameLbl);
            make.bottom.equalTo(_userIconImgv).offset(-4);
        }];
    }
    return self;
}

- (UIImageView *)userIconImgv {
    if (!_userIconImgv) {
        _userIconImgv = [[UIImageView alloc] init];
        _userIconImgv.backgroundColor = [UIColor lightGrayColor];
        _userIconImgv.layer.cornerRadius = kCX_Scale(35);
        _userIconImgv.layer.borderColor = [[UIColor grayColor] CGColor];
        _userIconImgv.layer.borderWidth = kCX_Scale(2);
    }
    return _userIconImgv;
}

- (UILabel *)nicknameLbl {
    if (!_nicknameLbl) {
        _nicknameLbl = [[UILabel alloc] init];
        _nicknameLbl.font = kMyFont(25);
        _nicknameLbl.textColor = [UIColor darkGrayColor];
    }
    return _nicknameLbl;
}

- (UILabel *)userIdLbl {
    if (!_userIdLbl) {
        _userIdLbl = [[UILabel alloc] init];
        _userIdLbl.font = kMyFont(17);
        _userIdLbl.textColor = [UIColor lightGrayColor];
    }
    return _userIdLbl;
}

#pragma mark - click action
- (void)clickAction:(UIControl *)sender {
    if (_clickAction) {
        _clickAction();
    }
}

@end
